﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Classifier
{
    class CUtils
    {
        public static string[][] ReadFileToArray(string fileName)
        {
            return ReadFileToArray(fileName, new char[] { ' ', '\t' });
        }

        public static string[][] ReadFileToArray(string fileName, char[] separator)
        {

            Stream inputStream = File.OpenRead(fileName);
            StreamReader sr = new StreamReader(inputStream);

            List<string[]> res = new List<string[]>();
            do
            {
                string line = sr.ReadLine();
                if (line == null || line.Length == 0)
                    break;

                string[] data = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                res.Add(data);
            } while (true);

            return res.ToArray();
        }

        public static string GetOpenFileName()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog();
            return openFileDialog.FileName;
        }
    }
}
